﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace WTSQCB
{
    public partial class DiemMonHoc : System.Web.UI.Page
    {
        private string chuoiketnoi = ConfigurationManager.ConnectionStrings["WebDiemTSQCBConnectionString"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow dong = DiemMonHocdgv.SelectedRow;
            MaHocVientxt.Text = HttpUtility.HtmlDecode(dong.Cells[1].Text);
            DiemQuaTrinhtxt.Text = HttpUtility.HtmlDecode(dong.Cells[5].Text);            
            DiemThitxt.Text = HttpUtility.HtmlDecode(dong.Cells[6].Text); 
        }

        protected void Suabtn_Click(object sender, EventArgs e)
        {

            try
            {
                GridViewRow dong = DiemMonHocdgv.SelectedRow;
                SqlConnection con = new SqlConnection(chuoiketnoi);
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "DiemMonHocSua";
                cmd.Parameters.AddWithValue("@mahocvien", MaHocVientxt.Text);
                cmd.Parameters.AddWithValue("@mamonhoc", dong.Cells[2].Text);
                cmd.Parameters.AddWithValue("@malop", dong.Cells[3].Text);
                cmd.Parameters.AddWithValue("@mahocki", dong.Cells[4].Text);
                cmd.Parameters.AddWithValue("@diemquatrinh", DiemQuaTrinhtxt.Text);
                cmd.Parameters.AddWithValue("@diemthi", DiemThitxt.Text);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                DiemMonHocdgv.DataBind();
                Response.Write("Sửa điểm thành công");
            }
            catch
            {
                Response.Write("không thực hiện được");
            }
        }
    }
}